package utils
{
	public class DateUtil
	{
		public static function addWeeks(date:Date, weeks:Number):Date {
			return addDays(date, weeks*7);
		}
		
		public static function addDays(date:Date, days:Number):Date {
			return addHours(date, days*24);
		}
		
		public static function addHours(date:Date, hrs:Number):Date {
			return addMinutes(date, hrs*60);
		}
		
		public static function addMinutes(date:Date, mins:Number):Date {
			return addSeconds(date, mins*60);
		}
		
		public static function addSeconds(date:Date, secs:Number):Date {
			var mSecs:Number = secs * 1000;
			var sum:Number = mSecs + date.getTime();
			return new Date(sum);
		}
        
        //把时间字符串转换成秒数
        public static  function parseTimeStringToSec(str:String):Number
        {
            var temp:Array = str.split("_");
            var dateStr:String = temp[0];
            var timeStr:String = temp[1];
            
            temp = dateStr.split("/");
            var year:Number = temp[0];
            var month:Number = temp[1];
            var day:Number = temp[2];
            
            temp = timeStr.split(":");
            var hour:Number = temp[0];
            var min:Number = temp[1];
            var sec:Number = temp[2];
            
            var mil:Number = new Date(year, month - 1, day, hour, min, sec).time;
            return Number(mil / 1000);
        }
		
	}
}